/**
 *
 * Application - The main entry point to the server
 *
 * @author Scot McSweeney-Roberts
 * @varesion 0.1
 *
 */

package uk.co.sheitgeist.fums.server.app

import uk.co.sheitgeist.fums.server.upnp.*
import uk.co.sheitgeist.fums.server.content.store.*
import uk.co.sheitgeist.fums.server.content.store.filesystem.*
import uk.co.sheitgeist.fums.server.content.transport.*
import uk.co.sheitgeist.fums.server.content.transport.http.*
import uk.co.sheitgeist.fums.server.content.context.*

import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.logging.LogManager;

class Application {

	private static Logger logger = Logger.getLogger("uk.co.sheitgeist");

	MediaServer mediaServer

	Application() {
		mediaServer = new MediaServer()
		
		FileSystemStore fs = new FileSystemStore(new File("/home/scot/media"))
		
		HTTPTransport http = new HTTPTransport()
		
		ContentContext context = new ContentContext("media", "media", fs, http)

	 	mediaServer.contentDirectory.addContentContext(context)
		Thread.startDaemon {http.start()}

	}

	public static void main(String[] args) {
		LogManager.logManager.readConfiguration()

		final Application app = new Application()
		println "upnp http port: ${app.mediaServer.port}"
		try {
		app.mediaServer.start()
		} catch (Exception exp) {
			logger.severe "something really wrong happened"
		}

	}

}
